$(function(){
	var taskId = getUrlParam('url');
	$("#sure").click(function(){
		$("#apply").attr("disabled",true);
		$.ajax({
			url:"../../applyTask.action",
			type:"post",
			data:{"taskid":taskId},
			dataType:"post",
			success:function(data)
			{
				alert(data);
				console.log(data);
				$('#myModal').modal('show');
			},
		});
	});
	$.ajax({
		url:"../../getTaskInform.action",
		type:"post",
		dateType:"json",
		data:{"taskid":taskId},
		success:function(data)
		{
			console.log(data);
			$("#body").append('<div class="col-md-8 col-md-offset-3">'
					+'<h2>'+data.taskname+'</h2>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>资金：'+data.commission+'元</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>起止时间：'+data.startDate+'~'+data.overDate+'</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>参与人数：'+data.joinnumber+'人</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>活动地点： '+data.city+'</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>图片：'
					+'<a href="/pic/'+data.picture+'"><span class="glyphicon glyphicon-download-alt" aria-hidden="true">下载</span></a></h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>发布人： '+data.releasername+'</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-4">'
					+'<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" id="apply">申请</button>'
					+'</div>');
		}
	});
	$.ajax({
		url:"../../getTaskAppInform.action",
		type:"post",
		dateType:"json",
		data:{"taskid":taskId},
		success:function(data)
		{
			console.log(data);
		}
	});
});


function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}